<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
    <style>
        .box{
            width: 258px;
            height: 80px;
            margin: 0 auto;
            overflow: hidden;
        }
        .one{
            width: 2000px;
        }
        img{
            width: 258px;
            height: 80px;
            float: left;
            position: relative;
        }
        .two{
            font-size: 25px;
            color: pink;
            position: relative;
        }
        .left{
            width: 25px;
            height: 35px;
            position: absolute;
            top: 23px;
            border: 1px solid red;
        }
        .right{
            width: 25px;
            height: 35px;
            position: absolute;
            top: 23px;
            left: 232px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="one">
            <img src="./img/11.png" alt="" style="left: 0px;">
            <img src="./img/22.png" alt="" style="left: 0px;">
            <img src="./img/33.jpg" alt="" style="left: 0px;">
            <img src="./img/44.png" alt="" style="left: 0px;">
        </div>
        <div class="two">
            <div class="left">&lt;</div>
            <div class="right">&gt;</div>
        </div>
    </div>

    <script>
        $('.left').click(function() {
            console.log(111);
        })
        let currentIndex = 0;
        let imgHeight = 258;
        let length = $('img').length
        function showPic() {
            currentIndex = currentIndex >= length - 1 ? 0 : ++currentIndex
            let distance = -currentIndex * imgHeight + 'px'
            $('img').animate({'left':distance},500)
        }
        let show = setInterval(showPic,1000)

        $('.left').click(function() {
            clearInterval(show)
            currentIndex = currentIndex <= 0 ? length - 1 : --currentIndex
            let distance = -currentIndex * imgHeight + 'px'
            $('img').animate({'left':distance},500)
        })

        $('.right').click(function() {
            clearInterval(show)
            currentIndex = currentIndex >= length - 1 ? 0 : ++currentIndex
            let distance = -currentIndex * imgHeight + 'px'
            $('img').animate({'left':distance},500)
        })
    </script>
</body>
</html>